﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.MachineSys.UserModel
{
    public partial class UClaimDemageControlDiffAnalyse : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.修改 };
            }
        }
        protected override string DWZRef
        {
            get { return "UClaimDemageControlList"; }
        }


        /// <summary>
        /// 需要修改的ID
        /// </summary>
        protected string ClaimsNumber
        {
            get
            {
                return GetRequestValue<string>("ClaimsNumber");
            }
        }

        private DataTable _SupplerDetailDT;
        protected DataTable SupplerDetailDT
        {
            get
            {
                if (_SupplerDetailDT == null)
                {
                    _SupplerDetailDT = UClaimDemageControlController.GetDetailByClaimsNumber(ClaimsNumber);
                }
                return _SupplerDetailDT;
            }
        }

        private UClaimDemageControlInfo _obj;
        protected UClaimDemageControlInfo obj
        {
            get
            {
                if (_obj == null)
                {
                    _obj = UClaimDemageControlController.GetByClaimsNumber(ClaimsNumber);
                }
                return _obj;
            }
        }


        private UClaimDemageControlDetailInfo _onlyworkObj;
        protected UClaimDemageControlDetailInfo onlyworkObj
        {
            get
            {
                if (_onlyworkObj == null)
                {
                    _onlyworkObj = UClaimDemageControlController.GetDetailByClaimsNumber2(ClaimsNumber).Find(e => e.OnlyWork == true);
                    if (_onlyworkObj == null)
                        _onlyworkObj = new UClaimDemageControlDetailInfo();
                }
                return _onlyworkObj;
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "edit")
            {
                addmenu();
            }
         //   this.rpAnalyse.DataSource = SupplerDetailDT;
            //this.rpAnalyse.DataBind();

        }

       
        private void addmenu()
        {
           // UClaimDemageControlInfo obj = Request.SerializableObject<UClaimDemageControlInfo>();
            obj.FinalDiffAnalyse = GetRequestValue<string>("FinalDiffAnalyse","");
            obj.SupplerDiffAnalyse = GetRequestValue<string>("SupplerDiffAnalyse", "");
            obj.DiffDuty = GetRequestValue<string>("DiffDuty", "");

            this.AddLog(Permission.修改, obj);

            bool r = UClaimDemageControlController.Update(obj);
            if (r)
                SuccessJson("保存成功", this.DWZRef);
            else
            {
                ErrorJson("保存失败", this.DWZRef);
            }
        }
    }
}